<!-- 我的团队 -->
<template>
	<view class="page_box">
		<view class="head_box">
		<!-- 	<ljshop-navbar :background="{ background: 'none' }" backText="对接人" backIconColor="#333"></ljshop-navbar> -->
			<view class="all-box u-flex-col u-row-center u-col-center" style="position: relative;">
					<button  @tap="toShenqing()" style="color: #fda22a;font-size:30rpx;background:rgba(255, 255, 255, .6);width:150rpx;;height: 55rpx;line-height: 55rpx;text-align: center;position: absolute;right: 15rpx;top:15rpx;"> 申请</button>
				<!-- <view class="u-flex" style="position: fixed;right: 120rpx;">
			
				</view> -->
				<text class="all-num">{{ TeamCount || 0 }}</text>
				<text class="all-title u-m-b-30">对接总数</text>
				<image class="score-card-bg" :src="$IMG_URL + '/imgs/score/score_wallet_bg.png'" mode=""></image>
			</view>
			<view class="tab-box u-flex">
				<view class="tab-item u-flex u-row-center " @tap="onTab('PENDING')"><view class="tab-name" :class="{ 'tab-active': tabCur === 'PENDING' }">等待审核</view></view>
				<view class="tab-item u-flex u-row-center" @tap="onTab('APPROVED')"><view class="tab-name" :class="{ 'tab-active': tabCur === 'APPROVED' }">审核通过</view></view>
				<view class="tab-item u-flex u-row-center" @tap="onTab('FAILED')"><view class="tab-name" :class="{ 'tab-active': tabCur === 'FAILED' }">审核失败</view></view>
			</view>
		</view>
		<view class="content_box">
			<scroll-view scroll-y="true" @scrolltolower="loadMore" class="scroll-box">
				<!-- <view class="item-box u-flex u-row-between" v-for="log in teamList" :key="log.id" @tap="toOrderList(log.store.id)"> -->
				<view class="item-box u-flex" v-for="log in teamList" :key="log.id" @tap="toOrderList(log.storeId)">	
					<view class="u-flex-col" style="width: 400rpx;">
						<view class="name">{{ log.store.name }}</view>
						<!-- <view class="time">{{ $u.timeFormat(log.createdDate) }}</view> -->
						<view class="time">{{ log.businessName }}</view>
					</view>
					<view class="u-flex-col" style="width: 400rpx;">
						<view class="name">联系人 </view>
						<!-- <view class="num font-OPPOSANS" >{{ log.member.name }}</view> -->
						<view class="name2">{{ log.name }}</view>
					</view>
					<view class="u-flex-col" style="width: 400rpx;">
						<view class="name">电话</view>
						<view class="name2">{{ log.mobile }}</view>
					</view>
				</view>
				<!-- 空置页 -->
				<!-- 更多 -->
				<u-loadmore v-if="teamList.length" height="80rpx" :status="loadStatus" icon-type="flower" color="#ccc" />
			</scroll-view>
		</view>
	</view>
</template>

<script>
 
	import {
		mapMutations,
		mapActions,
		mapState,
		mapGetters
	} from 'vuex';
	export default {
		components: {
		 
		},
		data() {
			return {
				isEmpty: false,
				referrerInfo: {}, //推荐人信息
				twoTeamCount: 0, //二级成员
				teamList: [], //团队列表
				loadStatus: 'loadmore', //loadmore-加载前的状态，loading-加载中的状态，nomore-没有更多的状态
				currentPage: 0,
				lastPage: 0,
                tabCur: 'PENDING',
				isRefresh: false,
				TeamCount:0
			};
		},
		computed: {
			...mapGetters(['userInfo', 'agentInfo'])
		},
		onLoad() {
			this.getTeam();

		},
		methods: {
			...mapActions(['getAgent']),

           onTab(type) {
			if (this.tabCur !== type) {
				this.tabCur = type;
				this.teamList = [];
				this.currentPage = 0;
				this.getTeam();
			}
		},
			getTeam() {
				let that = this;
				that.loadStatus = 'loadmore';
				that.$http('commission.teamservice', {
					page: that.currentPage,
					UId: uni.getStorageSync("UId"),
          statusEnum:this.tabCur
				}).then(res => {
					if (res) {
						that.referrerInfo = res;
						let arr = res.data.list;
						that.teamList = res.data.list;
						that.TeamCount = res.data.count;
						that.isEmpty = !that.teamList.length;
						if(res.data.list.length<20){
							that.loadStatus="nomore"
						}
					}
				});
			},
			toOrderList(id){
				console.log(id)
				 // if(this.tabCur != "APPROVED"){
					//  return
				 // }
				this.$Router.push({
					path: "/pages/app/commission/waiterOrderlist",
					query: {
						storeId:id
					}
					
				});
			},
			// 加载更多
			loadMore() {
				if (this.currentPage < this.lastPage) {
					this.currentPage += 1;
					this.getTeam();
				}
			},
			toShenqing(){
				this.$Router.push({
					path: "/pages/public/storesearch",
				});
			}
		}
	};
</script>

<style lang="scss">
	// 推荐人
	.referrer-box {
		font-size: 28rpx;
		font-weight: 500;
		color: #ffffff;
		margin-top: 10rpx;
	
	.referrer-avatar {
			width: 34rpx;
			height: 34rpx;
			border-radius: 50%;
		}
	}

	// 二级加载更多按钮
	.refresh-btn {
		width: 100%;
		line-height: 100rpx;
		background: #ffffff;
		border-radius: 25rpx;
		font-size: 22rpx;
		font-weight: 500;
		color: #999999;
		white-space: nowrap;
	}

	.refresh-active {
		transform: rotate(360deg);
		transition: all linear 0.5s;
	}

	// 头部卡片
	.head_box {
		background: url($IMG_URL+'/imgs/commission/card_bg.png') no-repeat;
		background-size: 100% 100%;
		padding-bottom: 30rpx;
	}

	// 团队信息总览
	.team-data-box {
		margin: 30rpx 20rpx 0;

		.data-card {
			width: 750rpx;
			background: #ffffff;
			border-radius: 20rpx;
			padding: 20rpx;

			.item-title {
				font-size: 22rpx;
				font-weight: 500;
				color: #999999;
				line-height: 30rpx;
				margin-bottom: 10rpx;
				text-align: center;
			}

			.total-item {
				margin-bottom: 20rpx;
			}

			.total-num {
				font-size: 38rpx;
				font-weight: 500;
				color: #333333;
				text-align: center;
			}

			.category-num {
				font-size: 26rpx;
				font-weight: 500;
				color: #333333;
				text-align: center;
			}
		}
	}

	// 团队列表
	.team-box {
		.team-list {
			.team-children {
				margin-left: 80rpx;
				margin-right: 20rpx;
				height: 132rpx;
				border-bottom: 1rpx solid #eee;

				.head-img {
					width: 60rpx;
					height: 60rpx;
					border-radius: 50%;
					margin-right: 38rpx;
				}

				.head-info {
					.head-time {
						font-size: 22rpx;
						font-weight: 400;
						color: #999999;
					}

					.name-box {
						margin-bottom: 12rpx;

						.name-text {
							font-size: 24rpx;
							font-weight: 500;
							color: #666;
						}

						.tag-box {
							background: rgba(0, 0, 0, 0.2);
							border-radius: 21rpx;
							line-height: 30rpx;
							padding-right: 10rpx;
							margin-left: 10rpx;

							.tag-img {
								width: 34rpx;
								height: 34rpx;
								margin-right: 6rpx;
								border-radius: 50%;
							}

							.tag-title {
								font-size: 18rpx;

								font-weight: 500;
								color: rgba(255, 255, 255, 1);
								line-height: 20rpx;
							}
						}
					}
				}
			}
		}
	}

	.page_box {
		background: #fff;
		.head_box {
			width: 750rpx;
			background: linear-gradient(180deg, rgba(239, 196, 128, 1) 0%, rgba(248, 220, 165, 1) 40%, rgba(255, 255, 255, 1) 100%) no-repeat;
			position: relative;

			.all-box {
				height: 360rpx;
				padding-bottom: var(--status-bar-height);

				.all-num {
					font-size: 50rpx;
					font-weight: 500;
					color: #a8700d;
					margin-bottom: 20rpx;
				}

				.all-title {
					font-size: 24rpx;
					font-weight: 500;
					color: rgba(168, 112, 13, 1);
				}

				.score-card-bg {
					width: 100%;
					height: 90rpx;
				}
			}

			.tab-box {
				position: absolute;
				left: 50%;
				bottom: 0;
				transform: translateX(-50%);
				width: 710rpx;
				height: 90rpx;
				background: rgba(255, 255, 255, 1);
				border-radius: 30rpx 30rpx 0px 0px;
				border-bottom: 1rpx solid #dfdfdf;
				padding: 0 30rpx;

				.tab-item {
					flex: 1;

					.tab-name {
						display: inline-block;
						font-size: 30rpx;
						font-family: Noto Sans S Chinese;
						font-weight: 400;
						color: rgba(51, 51, 51, 1);
						border-bottom: 4rpx solid transparent;
						line-height: 86rpx;
					}

					.tab-active {
						border-bottom: 4rpx solid rgba(213, 166, 90, 1);
					}
				}
			}
		}
	}

	.item-box {
		background: #fff;
		border-bottom: 1rpx solid #dfdfdf;
		padding: 30rpx;

		.name {
			font-size: 28rpx;
			text-align: center;
			font-weight: 500;
			color: rgba(102, 102, 102, 1);
			line-height: 28rpx;
			margin-bottom: 20rpx;
		}
		.name2 {
			font-size: 28rpx;
			text-align: center;
			font-weight: 600;
			color: #1c1c1c;
			line-height: 28rpx;
			margin-bottom: 20rpx;
		}

		.time {
			font-size: 28rpx;

			font-weight: 600;
			color: #1c1c1c;
			line-height: 24px;
			
			word-break: break-all;
			text-overflow: ellipsis;
			display: -webkit-box;
			-webkit-box-orient: vertical;
			-webkit-line-clamp: 2;
			overflow: hidden;
		}

		.num {
			font-size: 30rpx;

			font-weight: 500;
			color: #e6b873;
		}
	}
</style>
